<!-- 单份合同 -->
<template>
  <div>
    <div class="eda-main-title">
      <div class="top-icon">
        <img src="../../../assets/img/personnelImage/创建流程图.png"/>
      </div>
      <div class="top-title">
        流程:创建 - 劳动合同 - 人事管理（单独签） - 创建
      </div>
      <div class="top-operate">
        <el-button type="primary" @click="submitForm">提交</el-button>
        <el-button type="primary" @click="backOff">取消</el-button>
      </div>
    </div>
    <div class="eda-main">
      <div class="main-middle">
        <el-form :model="formData" ref="vForm" :rules="rules" label-position="left" label-width="80px"
                 size="default" @submit.prevent>
          <div class="table-container">
            <table class="table-layout">
              <tbody>
              <tr>
                <td colspan="4"  style="background: rgb(244,244,244);padding-top: 15px;">
                  <div class="static-content-item" style="margin-left: 0">
                    <div>| 合同信息</div>
                  </div>
                </td>
              </tr>
              <tr>
                <td>
                  <div class="static-content-item">
                    <div>合同名称</div>
                  </div>
                </td>
                <td>
                  <el-form-item label="" label-width="0" prop="htm">
                    <el-input v-model="formData.htm" type="text" clearable></el-input>
                  </el-form-item>
                </td>
                <td>
                  <div class="static-content-item">
                    <div>合同编号</div>
                  </div>
                </td>
                <td>
                  <el-form-item label="" label-width="0" prop="processId">
                    <el-input v-model="formData.processId" type="text" clearable readonly></el-input>
                  </el-form-item>
                </td>
              </tr>
              <tr>
                <td>
                  <div class="static-content-item">
                    <div>合同开始日期</div>
                  </div>
                </td>
                <td>
                  <el-form-item label="" label-width="0" prop="start_date">
                    <el-date-picker v-model="formData.start_date" type="date" class="full-width-input"
                                    format="YYYY-MM-DD" value-format="YYYY-MM-DD" clearable></el-date-picker>
                  </el-form-item>
                </td>
                <td>
                  <div class="static-content-item">
                    <div>合同结束日期</div>
                  </div>
                </td>
                <td>
                  <el-form-item label="" label-width="0" prop="end_date">
                    <el-date-picker v-model="formData.end_date" type="date" class="full-width-input"
                                    format="YYYY-MM-DD" value-format="YYYY-MM-DD" clearable></el-date-picker>
                  </el-form-item>
                </td>
              </tr>
              <tr>
                <td colspan="4" style="background: rgb(244,244,244);padding-top: 15px">
                  <div class="static-content-item" style="margin-left: 0">
                    <div>| 人员信息</div>
                  </div>
                </td>
              </tr>
              <tr>
                <td>
                  <div class="static-content-item">
                    <div>员工姓名</div>
                  </div>
                </td>
                <td>
                  <el-input
                      class="inline-input"
                      v-model="formData.rid"
                      :value.async="formData.name"
                      placeholder="请输入内容"
                      readonly
                      clearable
                  ></el-input>
                </td>
                <td>
                  <div class="static-content-item">
                    <div>岗位</div>
                  </div>
                </td>
                <td>
                  <el-input class="inline-input" v-model="formData.position_name" readonly></el-input>
                </td>
              </tr>
              <tr>
                <td>
                  <div class="static-content-item">
                    <div>联系方式</div>
                  </div>
                </td>
                <td>
                  <el-input class="inline-input" v-model="formData.contactPhone" readonly></el-input>
                </td>
                <td>
                  <div class="static-content-item">
                    <div>所属部门</div>
                  </div>
                </td>
                <td>
                  <el-input class="inline-input" v-model="formData.ssbm" readonly></el-input>
                </td>
              </tr>
              <tr>
                <td>
                  <div class="static-content-item">
                    <div>工资</div>
                  </div>
                </td>
                <td>
                  <el-form-item label="" label-width="0" prop="month_wage">
                    <el-input v-model="formData.month_wage" type="text" clearable></el-input>
                  </el-form-item>
                </td>
                <td>
                  <div class="static-content-item">
                    <div>身份证</div>
                  </div>
                </td>
                <td>
                  <el-form-item label="" label-width="0" prop="idCard">
                    <el-input v-model="formData.idCard" type="text" clearable></el-input>
                  </el-form-item>
                </td>
              </tr>
              </tbody>
            </table>
          </div>
        </el-form>
      </div>
    </div>
  </div>
</template>

<script>
import {ConfirmRenew, initialInterface} from "../../../network/per/labor_contract";

export default {
  components: {},
  props: {},
  data() {
    return {
      accountData:JSON.parse(decodeURIComponent(this.$route.query.lcArr)),
      // 展示数据
      formData: {},
      arr: {
        resumeid:null,
        posid:null,
        lsct:null,
        pageSize: 5,
        pageNum: 1,
      },
      rules: {},
      // 后台数据
      backstage:{
        id:null,
        processId:"",
        startDate:"",
        endDate:"",
        monthWage:"",
        originContract:"",
        resumeId:null,
        status:1
      }
    }
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {
    let al = JSON.parse(decodeURIComponent(this.$route.query.lcArr));
    this.formData = al;
    this.formData.htm = "新人入职合同";
    this.formData.ssbm = "维森集团";

    initialInterface(this.arr).then((das)=>{
      console.log("lcmanage init ->",das)
      if (das.code === 200){
        this.fabtable = das.data.list;
      }
    });
  },
  methods: {
    backOff(){
      this.$router.push({path:'/per/lcm'})
    },
    submitForm() {
      this.$refs['vForm'].validate(valid => {
        if (!valid) return
        console.log(" --- > ",this.formData)
        this.backstage.id = this.formData.lcId;
        this.backstage.processId = this.formData.processId;
        this.backstage.startDate = this.formData.start_date;
        this.backstage.endDate = this.formData.end_date;
        this.backstage.monthWage = this.formData.month_wage;
        this.backstage.originContract = this.formData.htm
        this.backstage.resumeId = this.formData.rid

        //TODO: 提交表单
        ConfirmRenew(this.backstage).then((das)=>{
          if (das.code === 200){
            this.$notify({
              title: '成功',
              message: '这是一条成功的提示消息',
              type: 'success'
            })
          }else{
            this.$notify({
              title: '失败',
              message: '这是一条失败的提示消息',
              type: 'error'
            })
          }
          this.$router.push({name:'合同管理'});
        })
      })
    },
    resetForm() {
      this.$refs['vForm'].resetFields()
    },
  }
}

</script>

<style lang="scss" scoped>
@import "../../../assets/css/personnelCss/EDemandApp";
</style>